package com.scaffold.springmvc.action;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.context.request.async.DeferredResult;

class User{
	private static final long serialVersionUID = 2L;
	public void setName(String name) {
		this.name = name;
	}
	public int getUserid() {
		return userid;
	}
	public void setUserid(int userid) {
		this.userid = userid;
	}
	public String getName() {
		return name;
	}
	private int userid;
	private String name;
	@Override
	public String toString() {
		return "User [userid=" + userid + ", name=" + name + "]";
	}
	
}

@Controller
public class HelloAnnoAction {

	@RequestMapping("/helloAnno.do")
    public String helloAnno(String s ,User user) {
        System.out.println("helloAnno "+s+",user="+user);
        return "test.vm";
    }

	@RequestMapping(method=RequestMethod.GET, value="/helloRest/{id}")
    public String helloRest(@PathVariable int id) {
        System.out.println("helloRest "+id);
        return "helloAnno";
    }
	
	@RequestMapping(method=RequestMethod.GET, value="/helloRequest")
	public String helloRequest(HttpServletRequest request){
		System.out.println("request="+request.getParameterMap());
		return "helloAnno.vm";
	}
	
	@ResponseBody
	@RequestMapping("/quotes.xhtml")
	public DeferredResult quotes() {
	  DeferredResult deferredResult = new DeferredResult();
	  // Add deferredResult to a Queue or a Map...
	  return deferredResult;
	}
}
